#ifndef __DEFINE_MACRO_H__
#define __DEFINE_MACRO_H__

#define NONLOCK
#define READ_LOCK( LOCK )	aliww::CRwLock rwlock( LOCK, aliww::RLOCK );
#define WRITE_LOCK( LOCK )	aliww::CRwLock rwlock( LOCK, aliww::WLOCK );
#define MUTEX_LOCK( LOCK )	aliww::CMutexLock lock( LOCK )

#define DEFINE_MEMBER_ACCESS_CONTROL_LOCK(SPECIFIER, TYPE, NAME, RLOCK, WLOCK)	\
SPECIFIER:									\
	TYPE m##NAME;								\
public:										\
	TYPE& Get##NAME(){							\
		RLOCK;								\
		return m##NAME;							\
	}									\
	const TYPE& Get##NAME() const{						\
		RLOCK;								\
		return m##NAME;							\
	}									\
	void Set##NAME( const TYPE& tmp){					\
		WLOCK;								\
		m##NAME = tmp;							\
		return;								\
	}
#endif

#define DEFINE_MEMBER_PUBLIC_LOCK(TYPE, NAME, RLOCK, WLOCK)			\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(public, TYPE, NAME, RLOCK, WLOCK)

#define DEFINE_MEMBER_PROTECTED_LOCK(TYPE, NAME, RLOCK, WLOCK)			\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(protected, TYPE, NAME, RLOCK, WLOCK)

#define DEFINE_MEMBER_PRIVATE_LOCK(TYPE, NAME, RLOCK, WLOCK)			\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(private, TYPE, NAME, RLOCK, WLOCK)

#define DEFINE_MEMBER_PUBLIC(TYPE, NAME)					\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(public, TYPE, NAME, NONLOCK, NONLOCK)

#define DEFINE_MEMBER_PROTECTED(TYPE, NAME)					\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(protected, TYPE, NAME, NONLOCK, NONLOCK)

#define DEFINE_MEMBER_PRIVATE(TYPE, NAME)					\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(private, TYPE, NAME, NONLOCK, NONLOCK)

#define DEFINE_MEMBER_PUBLIC_RWLOCK(TYPE, NAME, LOCK)				\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(public, TYPE, NAME, READ_LOCK(LOCK), WRITE_LOCK(LOCK))

#define DEFINE_MEMBER_PROTECTED_RWLOCK(TYPE, NAME, LOCK)			\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(protected, TYPE, NAME, READ_LOCK(LOCK), WRITE_LOCK(LOCK))

#define DEFINE_MEMBER_PRIVATE_RWLOCK(TYPE, NAME, LOCK)				\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(private, TYPE, NAME, READ_LOCK(LOCK), WRITE_LOCK(LOCK))

#define DEFINE_MEMBER_PUBLIC_MUTEXLOCK(TYPE, NAME, LOCK)			\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(public, TYPE, NAME, MUTEX_LOCK(LOCK), MUTEX_LOCK(LOCK))

#define DEFINE_MEMBER_PROTECTED_MUTEXLOCK(TYPE, NAME, LOCK)			\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(protected, TYPE, NAME, MUTEX_LOCK(LOCK), MUTEX_LOCK(LOCK))

#define DEFINE_MEMBER_PRIVATE_MUTEXLOCK(TYPE, NAME, LOCK)			\
	DEFINE_MEMBER_ACCESS_CONTROL_LOCK(private, TYPE, NAME, MUTEX_LOCK(LOCK), MUTEX_LOCK(LOCK))

#define DEFINE_MEMBER DEFINE_MEMBER_PROTECTED
#define DEFINE_MEMBER_LOCK DEFINE_MEMBER_PUBLIC_MUTEXLOCK
